<?php

namespace app\common\validate;

use think\Db;
use think\Validate;

class Base extends Validate
{

    protected function exists($value, $rule, $data, $field, $fieldLang)
    {
        $arr = explode(',', $rule);
        if (count($arr) < 2) {
            return '规则设置不正确';
        }
        if (Db::name($arr[0])->where($arr[1], $value)->count() > 0) {
            return true;
        } else {
            return ':attribute不存在';
        }
    }

}